<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>新闻详情-WeAdmin Frame型后台管理系统-WeAdmin 1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="__STATIC__/admin/static/css/font.css">
		<link rel="stylesheet" href="__STATIC__/admin/static/css/weadmin.css">
    <script src="__STATIC__/admin/static/js/jquery3.2.1.min.js" charset="utf-8"></script>
    <script src="__STATIC__/admin/lib/layui/layui.js" charset="utf-8"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
    <div class="weadmin-body">
        <form class="layui-form">
          <div class="layui-form-item">
              <label for="title" class="layui-form-label">
                  <span class="we-red">*</span>新闻标题
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="title" name="title" required="" lay-verify="required" value="{$last[0]['title']}"
                  autocomplete="off" class="layui-input" disabled>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="id" class="layui-form-label">
                  <span class="we-red">*</span>所属分类
              </label>
              <div class="layui-input-inline">
                <select name="id" id="id">
                  {foreach $res1 as $v1}
                  <option value="{$v1['id']}" disabled>{$v1['name']}</option>
                    {foreach $res2 as $k2 => $v2}
                      {if $v2['parentid']==$v1['id']}
                      <option value="{$v2['id']}"
                        {if $k2>0}
                        disabled
                        {/if}
                        {if $last[0]['name']==$v2['name']}
                        selected
                        {/if}
                      >┗━━{$v2['name']}</option>
                      {/if}
                    {/foreach}
                  {/foreach}
                </select>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="desc" class="layui-form-label">
                  <span class="we-red">*</span>具体描述
              </label>
              <div class="layui-input-inline">
                  <textarea name="desc" id="desc" cols="30" rows="10"readonly>{$last[0]['content']}</textarea>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="image" class="layui-form-label">
                  <span class="we-red">*</span>图片
              </label>
              <div>
                {foreach $last[0]['allimg'] as $v3}
                <img src="{$v3}" width="100px" height="60px">
                {/foreach}
              </div>
          </div>
        </form>
    </div>
		<script src="__STATIC__/admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript">
    		layui.extend({
					admin: '{/}__STATIC__/admin/static/js/admin'
				});
        layui.use(['form','layer','admin'], function(){
          var form = layui.form,
          	admin = layui.admin,
          	layer = layui.layer;
          	form.render();
          //自定义验证规则
          form.verify({
            nikename: function(value){
              if(value.length < 5){
                return '昵称至少得5个字符啊';
              }
            }
            ,pass: [/(.+){6,12}$/, '密码必须6到12位']
            ,repass: function(value){
                if($('#L_pass').val()!=$('#L_repass').val()){
                    return '两次密码不一致';
                }
            }
          });

          //监听提交
          form.on('submit(add)', function(data){
            console.log(data);
            //发异步，把数据提交给php
            layer.alert("增加成功", {icon: 6},function () {
                // 获得frame索引
                var index = parent.layer.getFrameIndex(window.name);
                //关闭当前frame
                parent.layer.close(index);
            });
            return false;
          });
        });
    </script>
  </body>

</html>